package com.mycompany.j2eem.Mapper.ghymapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface PictureStoreMapper {

    //收藏图片
    @Insert("INSERT INTO Like_Picture(Account_id,Picture_id) VALUES(#{account},#{picture})")
    int Conner_picture(@Param("account") String account, @Param("picture") String picture);

    //取消收藏
    @Delete("Delete from Like_Picture where Account_id = #{account} and Picture_id = #{picture}")
    int Delete_Conner_picture(@Param("account") String account, @Param("picture") String picture);

    //获取已经发布过的动态信息
    @Select("Select title from Movement WHERE Account_id = #{id}")
    List<String> getMovement(@Param("id") String id);

    //获取图片信息(标签)
    @Select("Select TagName_id from Picture WHERE id = #{id}")
    List<String> getPictureTag(@Param("id") String id);

    //获取图片的发布者
    @Select("Select Account_id from PersonalHub,PersonalHub_picture WHERE PersonalHub_picture.PersonalHub_id=PersonalHub.id AND PersonalHub_picture.Picture_id= #{Picture_id}" )
    String getAccountID(@Param("Picture_id") String Picture_id);

    //获取收藏图片路径
    @Select("Select picturepath from Picture,Favorite_picture WHERE Favorite_id = #{id}  AND Picture_id = Picture.id")
    String getPicturePath(@Param("id") String id);

    //获取图片名字
    @Select("Select title from Movement WHERE Account_id = #{id}")
    String getMovementName(@Param("id") String id);

    //找到相应用户上传过的图片
    @Select("Select Picture_id from Like_Picture WHERE Account_id = #{id}")
    String getConnernedPicture(@Param("id") String id);

}
